using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;

public partial class admin_gallery_AlbumPreview : System.Web.UI.UserControl
{
	protected Album album;
	protected Photo photo;

	protected string url;
	protected string title;

	protected void Page_Load(object sender, EventArgs e)
	{
		if (Request.QueryString["AlbumId"] != null)
			album = Album.GetById(new Guid(Request.QueryString["AlbumId"]));

		if (Request.QueryString["PhotoId"] != null)
			photo = Photo.GetById(new Guid(Request.QueryString["PhotoId"]));

		if (photo != null)
			album = photo.Album;

		Visible = (album != null);
	}

	protected void Page_PreRender(object sender, EventArgs e)
	{
		if ((album != null) && (photo == null))
			photo = album.FirstPhoto;

		if (photo != null)
		{
			url = photo.GetSizedPhotoURL(150);
			title = photo.Title;
		}
		else
		{
			url = VirtualPathUtility.ToAbsolute("~/") + "pics/nophotos-150.jpg";
			title = "No Photos";
		}

	}
}
